﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class RecoverPassword : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    private void MessageBox(string msg)
    {
        Page.Controls.Add(new LiteralControl(
         "<script language='javascript'> window.alert('" + msg.Replace("'", "\\'") + "');</script>"));
    }

    protected void PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e)
    {
        e.Cancel = true;
        try
        {
            System.Net.Mail.SmtpClient mailclient = new System.Net.Mail.SmtpClient();
            System.Net.NetworkCredential auth = new System.Net.NetworkCredential("ngothanhquang08@gmail.com", "thanhquang");
            mailclient.Host = "smtp.gmail.com";
            mailclient.EnableSsl = true;
            mailclient.UseDefaultCredentials = true;
            mailclient.Credentials = auth;
            mailclient.Send(e.Message); 
            Response.Redirect("ResetThanhCong.aspx");
        }
   
        catch (Exception ex)
        {
            //Console.WriteLine("Exception is:" + ex.ToString());
		    throw ex; //or return the error by some other means, say on a label
        }
    }
}
